<?php
/*********************************************
  CPG Dragonfly™ CMS
  ********************************************
  Copyright © 2004 - 2005 by CPG-Nuke Dev Team
  http://www.dragonflycms.com

  Dragonfly is released under the terms and conditions
  of the GNU GPL version 2 or any later version
**********************************************/
if (!defined('ADMIN_PAGES')) { exit; }
if (!can_admin('forums')) { die('Access Denied'); }

global $db,$lang;

$showblocks = 0;

if (empty($_POST['send_file']) && !isset($_POST['cancel'])) {
	require('header.php');
	define('IN_PHPBB', 1);
	$module_name = ($op == 'forums') ? ucfirst($op) : $op;
	$phpbb_root_path = "modules/$module_name/";
	define('IN_ADMIN', true);
	require($phpbb_root_path.'common.php');
	$userdata = session_pagestart($user_ip, PAGE_INDEX);
	init_userprefs($userdata);
	$newimage = file_exists("themes/$CPG_SESS[theme]/images/new.gif") ? $CPG_SESS['theme'] : 'default';
	OpenTable();
	echo '<nav class="menu"><ul>
		<li>'._BBFORUMS.'
			<ul>
				<li><a href="'.URL::admin('&do=forums').'">'.$lang['Manage'].'</a></li>
				<li><a href="'.URL::admin('&do=forumauth').'">'.$lang['Auth_Control_Forum'].'</a></li>
				<li><a href="'.URL::admin('&do=forum_archive').'">'.$lang['Archive'].'</a></li>
				<li><a href="'.URL::admin('&do=forum_prune').'">'.$lang['Prune'].'</a></li>
				<li><hr/></li>
				<li><a href="'.URL::admin('&do=config').'">'.$lang['Configuration'].'</a></li>
				<li><hr/></li>
				<li><a href="'.URL::admin('&do=avatar').'">'.$lang['Avatar_panel'].'</a></li>
				<li><a href="'.URL::admin('&do=words').'">'.$lang['Word_Censor'].'</a></li>
				<li><a href="'.URL::admin('&do=topic_icons').'">'.$lang['Topic_icons'].'</a></li>
			</ul>
		</li>

		<li>'._BMEM.'
			<ul>
				<li><a href="'.URL::admin('&do=user_forums').'">'.$lang['User_Forum_Privileges'].'</a></li>
				<li><a href="'.URL::admin('&do=ug_auth&mode=user').'">'.$lang['Auth_Control_User'].'</a></li>
				<li><a href="'.URL::admin('&do=ug_auth&mode=group').'">'.$lang['Auth_Control_Group'].'</a></li>
			</ul>
		</li>

		<li>'.$lang['Attachments'].'
			<ul>
				<li><a href="'.URL::admin('&do=attach_cp').'">'.$lang['Control_Panel'].'</a></li>
				<li><hr/></li>
				<li><a href="'.URL::admin('&do=attachments&mode=manage').'">'.$lang['Attach_settings'].'</a></li>
				<li><a href="'.URL::admin('&do=attachments&mode=shadow').'">'.$lang['Shadow_attachments'].'</a></li>
				<li><a href="'.URL::admin('&do=attachments&mode=cats').'">'.$lang['Special_categories'].'</a></li>
				<li><a href="'.URL::admin('&do=attachments&mode=sync').'">'.$lang['Sync_attachments'].'</a></li>
				<li><a href="'.URL::admin('&do=attachments&mode=quota').'">'.$lang['Quota_limits'].'</a></li>
				<li><hr/></li>
				<li><a href="'.URL::admin('&do=groups').'">Group quota</a></li>
				<li><hr/></li>
				<li><a href="'.URL::admin('&do=extensions&mode=extensions').'">'.$lang['Extension_control'].'</a></li>
				<li><a href="'.URL::admin('&do=extensions&mode=groups').'">Extension group manage</a></li>
				<li><a href="'.URL::admin('&do=extensions&mode=forbidden').'">'.$lang['Forbidden_extensions'].'</a></li>
			</ul>
		</li>
	</ul></nav>';
}

$file = (isset($_GET['do']) ? $_GET['do'] : (isset($_POST['do']) ? $_POST['do'] : false));
$file = $file ? "admin_$file" : 'index';
if (!preg_match('#^([a-zA-Z0-9_\-]+)$#', $file)) { cpg_error(sprintf(_ERROR_BAD_CHAR, strtolower(_BBFORUMS)), _SEC_ERROR); }

if (Dragonfly::isDemo() && $file == 'admin_users') $file = 'index';

require_once("admin/modules/forums/$file.php");

if (empty($_POST['send_file']) && !isset($_POST['cancel'])) {
	$template->display('body');
	CloseTable();
}
